//
//  HNSH_ChatNetServer.m
//  HNSH_SingleProject
//
//  Created by 李宇廷 on 2023/2/16.
//

#import "HNSH_ChatNetServer.h"
#import "HNSH_NetConst.h"

@implementation HNSH_ChatNetServer

//获取好友列表
+ (NSURLSessionTask *)requestRongCloudFriendshipListSuccess:(ST_DataRequestSuccess)success Failure:(ST_RequestFailure)failure {
    return [ST_BaseNetManager requestMethod:HttpMethodGet urlString:URL_RongCloud_Friendship_List params:@{} from:YES success:success failure:failure];
}

//获取好友详情
+ (NSURLSessionTask *)requestRongCloudFriendDetailWithRcUserId:(NSString *)rcUserId success:(ST_DataRequestSuccess)success Failure:(ST_RequestFailure)failure {
    NSDictionary * params = @{@"cloudUserId":rcUserId};
    return [ST_BaseNetManager requestMethod:HttpMethodGet urlString:URL_RongCloud_UserInfo params:params from:YES success:success failure:failure];
}

//好友【删除】
+ (NSURLSessionTask *)requestRongCloudFriendshipDeleteWithRcUserId:(NSString *)rcUserId success:(ST_DataRequestSuccess)success Failure:(ST_RequestFailure)failure {
    NSDictionary * params = @{@"target_id":rcUserId};
    return [ST_BaseNetManager requestMethod:HttpMethodPost urlString:URL_RongCloud_Friendship_Delete params:params from:NO success:success failure:failure];
}

//好友【更新】备注
+ (NSURLSessionTask *)requestRongCloudFriendshipUpdateWithRcUserId:(NSString *)rcUserId display_name:(NSString *)display_name success:(ST_DataRequestSuccess)success Failure:(ST_RequestFailure)failure {
    NSDictionary * params = @{@"target_id":rcUserId,@"display_name":display_name};
    return [ST_BaseNetManager requestMethod:HttpMethodPost urlString:URL_RongCloud_Friendship_Update params:params from:NO success:success failure:failure];
}

//举报用户
+ (NSURLSessionTask *)requestRongCloudFriendshipReportWithRcUserId:(NSString *)rcUserId reason:(NSString *)reason success:(ST_DataRequestSuccess)success Failure:(ST_RequestFailure)failure {
    NSDictionary * params = @{@"targetUserId":rcUserId,@"reason":reason};
    return [ST_BaseNetManager requestMethod:HttpMethodPost urlString:URL_RongCloud_Report params:params from:NO success:success failure:failure];
}

//好友【申请】
+ (NSURLSessionTask *)requestRongCloudFriendshipInviteWithRcUserId:(NSString *)rcUserId message:(NSString *)message display_name:(NSString *)display_name target_type:(NSString *)target_type success:(ST_DataRequestSuccess)success Failure:(ST_RequestFailure)failure {
    NSDictionary * params = @{@"target_id":rcUserId,
                              @"message":message,
                              @"display_name":display_name};
    NSMutableDictionary *mutDict = [NSMutableDictionary dictionaryWithDictionary:params];
    if ([target_type isNotBlank]) {
        [mutDict setValue:target_type forKey:@"target_type"];
    }
    return [ST_BaseNetManager requestMethod:HttpMethodPost urlString:URL_RongCloud_Friendship_Invite params:mutDict from:NO success:success failure:failure];
}

//用户搜索
+ (NSURLSessionTask *)requestRongCloudFriendshipSearchUserWithSearchKey:(NSString *)search_key success:(ST_DataRequestSuccess)success Failure:(ST_RequestFailure)failure {
    NSDictionary * params = @{@"search_key":search_key};
    return [ST_BaseNetManager requestMethod:HttpMethodPost urlString:URL_RongCloud_SearchUser params:params from:NO success:success failure:failure];
}

//创建群聊
+ (NSURLSessionTask *)requestRongCloudGroupCreateWithUserIds:(NSArray *)userIds success:(ST_DataRequestSuccess)success Failure:(ST_RequestFailure)failure {
    NSDictionary * params = @{@"member_ids":userIds};
    return [ST_BaseNetManager requestMethod:HttpMethodPost urlString:URL_RongCloud_Group_Create params:params from:NO success:success failure:failure];
}


//二维码信息【其他】
+ (NSURLSessionTask *)requestRongCloudGroupQrcodeinfoWithQrcode:(NSString *)qrcode success:(ST_DataRequestSuccess)success Failure:(ST_RequestFailure)failure {
    NSDictionary * params = @{@"qrcode":qrcode};
    return [ST_BaseNetManager requestMethod:HttpMethodGet urlString:URL_RongCloud_Group_Qrcode_info params:params from:YES success:success failure:failure];
}


//二维码信息【自己】
+ (NSURLSessionTask *)requestRongCloudGroupQrcodeWithGroupId:(NSString *)groupId success:(ST_DataRequestSuccess)success Failure:(ST_RequestFailure)failure {
    NSDictionary * params = @{@"groupId":groupId};
    return [ST_BaseNetManager requestMethod:HttpMethodGet urlString:URL_RongCloud_Group_Qrcode params:params from:YES success:success failure:failure];
}


//申请加群
+ (NSURLSessionTask *)requestRongCloudGroupJoinWithQrcode:(NSString *)qrcode success:(ST_DataRequestSuccess)success Failure:(ST_RequestFailure)failure {
    NSDictionary * params = @{@"qrcode":qrcode};
    return [ST_BaseNetManager requestMethod:HttpMethodPost urlString:URL_RongCloud_Group_Join params:params from:NO success:success failure:failure];
}


//群成员信息【分页】
+ (NSURLSessionTask *)requestRongCloudGroupMemberListWithGroupId:(NSString *)groupId pageNum:(NSInteger)pageNum success:(ST_DataRequestSuccess)success Failure:(ST_RequestFailure)failure {
    NSDictionary * params = @{@"groupId":groupId,@"pageNum":@(pageNum),@"pageSize":@(1000)};
    return [ST_BaseNetManager requestMethod:HttpMethodGet urlString:URL_RongCloud_Group_Member_List params:params from:YES success:success failure:failure];
}


//获取群信息
+ (NSURLSessionTask *)requestRongCloudGroupInfoWithGroupId:(NSString *)groupId success:(ST_DataRequestSuccess)success Failure:(ST_RequestFailure)failure {
    NSString * url = [NSString stringWithFormat:URL_RongCloud_Group, groupId];
    return [ST_BaseNetManager requestMethod:HttpMethodGet urlString:url params:@{} from:YES success:success failure:failure];
}


//退出群聊
+ (NSURLSessionTask *)requestRongCloudGroupQuitWithGroupId:(NSString *)groupId success:(ST_DataRequestSuccess)success Failure:(ST_RequestFailure)failure {
    NSDictionary * params = @{@"group_id":groupId};
    return [ST_BaseNetManager requestMethod:HttpMethodPost urlString:URL_RongCloud_Group_Quit params:params from:NO success:success failure:failure];
}


//群成员信息
+ (NSURLSessionTask *)requestRongCloudGroupMembersWithGroupId:(NSString *)groupId success:(ST_DataRequestSuccess)success Failure:(ST_RequestFailure)failure {
    NSString * url = [NSString stringWithFormat:URL_RongCloud_Group_Members, groupId];
    return [ST_BaseNetManager requestMethod:HttpMethodGet urlString:url params:@{} from:YES success:success failure:failure];
}


//群聊好友编号
+ (NSURLSessionTask *)requestRongCloudGroupFriendWithGroupId:(NSString *)groupId success:(ST_DataRequestSuccess)success Failure:(ST_RequestFailure)failure {
    NSDictionary * params = @{@"groupId":groupId};
    return [ST_BaseNetManager requestMethod:HttpMethodGet urlString:URL_RongCloud_Group_Friend params:params from:YES success:success failure:failure];
}


//添加群成员
+ (NSURLSessionTask *)requestRongCloudGroupAddWithGroupId:(NSString *)groupId member_ids:(NSArray *)member_ids success:(ST_DataRequestSuccess)success Failure:(ST_RequestFailure)failure {
    NSDictionary * params = @{@"group_id":groupId,@"member_ids":member_ids};
    return [ST_BaseNetManager requestMethod:HttpMethodPost urlString:URL_RongCloud_Group_Add params:params from:NO success:success failure:failure];
}


//移除群成员
+ (NSURLSessionTask *)requestRongCloudGroupKickWithGroupId:(NSString *)groupId member_ids:(NSArray *)member_ids success:(ST_DataRequestSuccess)success Failure:(ST_RequestFailure)failure {
    NSDictionary * params = @{@"group_id":groupId,@"member_ids":member_ids};
    return [ST_BaseNetManager requestMethod:HttpMethodPost urlString:URL_RongCloud_Group_Kick params:params from:NO success:success failure:failure];
}

//批量增加管理员
+ (NSURLSessionTask *)requestRongCloudGroupManagerAddWithGroupId:(NSString *)groupId member_ids:(NSArray *)member_ids success:(ST_DataRequestSuccess)success Failure:(ST_RequestFailure)failure {
    NSDictionary * params = @{@"group_id":groupId,@"member_ids":member_ids};
    return [ST_BaseNetManager requestMethod:HttpMethodPost urlString:URL_RongCloud_Group_Manager_Add params:params from:NO success:success failure:failure];
}


//批量删除管理员
+ (NSURLSessionTask *)requestRongCloudGroupManagerRemoveWithGroupId:(NSString *)groupId member_ids:(NSArray *)member_ids success:(ST_DataRequestSuccess)success Failure:(ST_RequestFailure)failure {
    NSDictionary * params = @{@"group_id":groupId,@"member_ids":member_ids};
    return [ST_BaseNetManager requestMethod:HttpMethodPost urlString:URL_RongCloud_Group_Manager_Remove params:params from:NO success:success failure:failure];
}


//融云群聊【修改群头像】
+ (NSURLSessionTask *)requestRongCloudGroupChangePortraitWithGroupId:(NSString *)groupId portrait_url:(NSString *)portrait_url success:(ST_DataRequestSuccess)success Failure:(ST_RequestFailure)failure {
    NSDictionary * params = @{@"group_id":groupId,@"portrait_url":portrait_url};
    return [ST_BaseNetManager requestMethod:HttpMethodPost urlString:URL_RongCloud_Group_Chage_Portrait params:params from:NO success:success failure:failure];
}


//融云群聊【添加直推粉丝】
+ (NSURLSessionTask *)requestRongCloudGroupInviteFansWithGroupId:(NSString *)groupId success:(ST_DataRequestSuccess)success Failure:(ST_RequestFailure)failure {
    NSDictionary * params = @{@"group_id":groupId};
    return [ST_BaseNetManager requestMethod:HttpMethodPost urlString:URL_RongCloud_Group_Invite_Fans params:params from:NO success:success failure:failure];
}


//重命名群聊
+ (NSURLSessionTask *)requestRongCloudGroupRenameWithGroupId:(NSString *)groupId name:(NSString *)name success:(ST_DataRequestSuccess)success Failure:(ST_RequestFailure)failure {
    NSDictionary * params = @{@"group_id":groupId,@"name":name};
    return [ST_BaseNetManager requestMethod:HttpMethodPost urlString:URL_RongCloud_Group_Rename params:params from:NO success:success failure:failure];
}


//发布群公告
+ (NSURLSessionTask *)requestRongCloudGroupChangeBulletinWithGroupId:(NSString *)groupId bulletin:(NSString *)bulletin success:(ST_DataRequestSuccess)success Failure:(ST_RequestFailure)failure {
    NSDictionary * params = @{@"group_id":groupId,@"bulletin":bulletin};
    return [ST_BaseNetManager requestMethod:HttpMethodPost urlString:URL_RongCloud_Group_Change_Bulletin params:params from:NO success:success failure:failure];
}


//群状态切换
+ (NSURLSessionTask *)requestRongCloudGroupSwitchStatusWithGroupId:(NSString *)groupId switch_type:(NSInteger )switch_type success:(ST_DataRequestSuccess)success Failure:(ST_RequestFailure)failure {
    NSDictionary * params = @{@"group_id":groupId,@"switch_type":@(switch_type)};
    return [ST_BaseNetManager requestMethod:HttpMethodPost urlString:URL_RongCloud_Group_Switch_Status params:params from:NO success:success failure:failure];
}


//解散群
+ (NSURLSessionTask *)requestRongCloudGroupDismissWithGroupId:(NSString *)groupId success:(ST_DataRequestSuccess)success Failure:(ST_RequestFailure)failure {
    NSDictionary * params = @{@"group_id":groupId};
    return [ST_BaseNetManager requestMethod:HttpMethodPost urlString:URL_RongCloud_Group_Dismiss params:params from:NO success:success failure:failure];
}


//申请加群列表
+ (NSURLSessionTask *)requestRongCloudGroupApplyListWithGroupId:(NSString *)groupId success:(ST_DataRequestSuccess)success Failure:(ST_RequestFailure)failure {
    NSString * url = [NSString stringWithFormat:@"%@?groupId=%@", URL_RongCloud_Group_Apply_List, groupId];
    return [ST_BaseNetManager requestMethod:HttpMethodGet urlString:url params:@{} from:YES success:success failure:failure];
}


//好友【未读数量】
+ (NSURLSessionTask *)requestRongCloudFriendshipUnreadCountSuccess:(ST_DataRequestSuccess)success Failure:(ST_RequestFailure)failure {
    return [ST_BaseNetManager requestMethod:HttpMethodGet urlString:URL_RongCloud_Friendship_Unread_Count params:@{} from:YES success:success failure:failure];
}


//群申请同意
+ (NSURLSessionTask *)requestRongCloudGroupAgreeWithRcUserId:(NSString *)rcUserId success:(ST_DataRequestSuccess)success Failure:(ST_RequestFailure)failure {
    NSDictionary * params = @{@"id":rcUserId};
    return [ST_BaseNetManager requestMethod:HttpMethodPost urlString:URL_RongCloud_Group_Agree params:params from:NO success:success failure:failure];
}


//设置群名称备注
+ (NSURLSessionTask *)requestRongCloudGroupChangeUpdateDisplayNameWithGroupId:(NSString *)groupId name:(NSString *)name success:(ST_DataRequestSuccess)success Failure:(ST_RequestFailure)failure {
    NSDictionary * params = @{@"group_id":groupId,@"name":name};
    return [ST_BaseNetManager requestMethod:HttpMethodPost urlString:URL_RongCloud_Group_Update_Display_Name params:params from:NO success:success failure:failure];
}


//查询用户列表和群列表
+ (NSURLSessionTask *)requestRongCloudGroupInfoListWithGroupIds:(NSArray *)groupIds ids:(NSArray *)ids success:(ST_DataRequestSuccess)success Failure:(ST_RequestFailure)failure {
    NSDictionary * params = @{@"group_ids":groupIds,@"ids":ids};
    return [ST_BaseNetManager requestMethod:HttpMethodPost urlString:URL_RongCloud_Info_List params:params from:NO success:success failure:failure];
}


//融云群聊【官方群】
+ (NSURLSessionTask *)requestRongCloudGroupSpecialListSuccess:(ST_DataRequestSuccess)success Failure:(ST_RequestFailure)failure {
    return [ST_BaseNetManager requestMethod:HttpMethodGet urlString:URL_RongCloud_Group_Special_List params:@{} from:YES success:success failure:failure];
}


//融云群聊【申请加群】
+ (NSURLSessionTask *)requestRongCloudGroupApplyWithGroupId:(NSString *)groupId success:(ST_DataRequestSuccess)success Failure:(ST_RequestFailure)failure {
    NSDictionary * params = @{@"group_id":groupId};
    return [ST_BaseNetManager requestMethod:HttpMethodPost urlString:URL_RongCloud_Group_Apply params:params from:NO success:success failure:failure];
}


//新的好友【列表】
+ (NSURLSessionTask *)requestRongCloudNewFriendshipListSuccess:(ST_DataRequestSuccess)success Failure:(ST_RequestFailure)failure {
    NSString *urlString = [NSString stringWithFormat:@"%@?type=1",URL_RongCloud_Friendship_List];
    return [ST_BaseNetManager requestMethod:HttpMethodGet urlString:urlString params:@{} from:YES success:success failure:failure];
}


//批量获取用户信息
+ (NSURLSessionTask *)requestRongCloudUserInfoListWithParams:(NSDictionary *)params success:(ST_DataRequestSuccess)success Failure:(ST_RequestFailure)failure {
    return [ST_BaseNetManager requestMethod:HttpMethodPost urlString:URL_RongCloud_UserInfoList params:params from:NO success:success failure:failure];
}


//融云好友【拒绝】
+ (NSURLSessionTask *)requestRongCloudFriendshipIgnoreWithRcUserId:(NSString *)rcUserId success:(ST_DataRequestSuccess)success Failure:(ST_RequestFailure)failure {
    NSDictionary * params = @{@"target_id":rcUserId};
    return [ST_BaseNetManager requestMethod:HttpMethodPost urlString:URL_RongCloud_Friendship_Ignore params:params from:NO success:success failure:failure];
}


//好友【同意】
+ (NSURLSessionTask *)requestRongCloudFriendshipAgreeWithRcUserId:(NSString *)rcUserId name:(NSString *)name success:(ST_DataRequestSuccess)success Failure:(ST_RequestFailure)failure {
    NSDictionary * params = @{@"target_id":rcUserId, @"display_name":name};
    return [ST_BaseNetManager requestMethod:HttpMethodPost urlString:URL_RongCloud_Friendship_Agree params:params from:NO success:success failure:failure];
}


//群聊列表
+ (NSURLSessionTask *)requestRongCloudGroupListWithPage:(NSInteger)pageNum success:(ST_DataRequestSuccess)success Failure:(ST_RequestFailure)failure {
    NSString *urlString = [NSString stringWithFormat:@"%@?pageSize=10&pageNum=%ld",URL_RongCloud_Group_List,pageNum];
    return [ST_BaseNetManager requestMethod:HttpMethodGet urlString:urlString params:@{} from:YES success:success failure:failure];
}


#pragma mark 融云自定义红包模块
//发红包
+ (NSURLSessionTask *)requestRongCloudRedPacketSendWithGroupId:(NSString *)group_id pay_password:(NSString *)pay_password title:(NSString *)title quantity:(NSString *)quantity amount:(NSString *)amount success:(ST_DataRequestSuccess)success Failure:(ST_RequestFailure)failure {
    NSDictionary *params = @{@"group_id":group_id,
                             @"pay_password":pay_password,
                             @"title":title,
                             @"quantity":quantity,
                             @"amount":amount};
    return [ST_BaseNetManager requestMethod:HttpMethodPost urlString:URL_RongCloud_RedPacket_Send params:params from:NO success:success failure:failure];
}


//红包详情
+ (NSURLSessionTask *)requestRongCloudRedPacketDetailWithRedId:(NSString *)redId success:(ST_DataRequestSuccess)success Failure:(ST_RequestFailure)failure {
    NSString *urlString = [NSString stringWithFormat:@"%@%@",URL_RongCloud_RedPacket_Detail,redId];
    return [ST_BaseNetManager requestMethod:HttpMethodGet urlString:urlString params:@{} from:YES success:success failure:failure];
}


//红包记录
+ (NSURLSessionTask *)requestRongCloudRedPacketRecordWithPage:(NSInteger)pageNum selectIndex:(NSInteger)selectIndex success:(ST_DataRequestSuccess)success Failure:(ST_RequestFailure)failure {
    NSString *urlString = [NSString stringWithFormat:@"%@?pageSize=10&pageNum=%ld",URL_RongCloud_RedPacket_Open_Record,pageNum];
    if (selectIndex == 1) {
        urlString = [NSString stringWithFormat:@"%@?pageSize=10&pageNum=%ld",URL_RongCloud_RedPacket_Send_Record,pageNum];
    }
    return [ST_BaseNetManager requestMethod:HttpMethodGet urlString:urlString params:@{} from:YES success:success failure:failure];
}


//红包信息【群列表点击红包触发】
+ (NSURLSessionTask *)requestRongCloudRedPacketOpenInfoWithRedId:(NSString *)redId success:(ST_DataRequestSuccess)success Failure:(ST_RequestFailure)failure {
    NSString *urlString = [NSString stringWithFormat:@"%@%@",URL_RongCloud_RedPacket_Open_Info,redId];
    return [ST_BaseNetManager requestMethod:HttpMethodGet urlString:urlString params:@{} from:YES success:success failure:failure];
}


//拆红包
+ (NSURLSessionTask *)requestRongCloudRedPacketOpenWithRedId:(NSString *)redId success:(ST_DataRequestSuccess)success Failure:(ST_RequestFailure)failure {
    NSString *urlString = [NSString stringWithFormat:@"%@%@",URL_RongCloud_RedPacket_Open,redId];
    return [ST_BaseNetManager requestMethod:HttpMethodPost urlString:urlString params:@{} from:YES success:success failure:failure];
}


@end
